// pages/family/profile.js
const App=getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        
    },
    handleinput(e){
        console.log(e)
        let name=e.currentTarget.dataset.name
        if(name=="mingcheng"){
            this.setData({
                team_name:e.detail.value
            })
        }else{
            this.setData({
                team_remark:e.detail.value
            })
        }
    },
    //上传图片
			upload() {
				wx.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						wx.showLoading({
							title:"上传中"
						})
                        let file = res.tempFilePaths[0]
                       
						wx.uploadFile({
							url: App.api_root + 'upload/image', //仅为示例，非真实的接口地址
							filePath: file,
							name: 'iFile',
							formData: {
                                wxapp_id: App.getWxappId(),
                                token: wx.getStorageSync('token')
							},
							success: (res) => {
								wx.hideLoading()
								let user = JSON.parse(res.data)							
								this.setData({
                                    team_avatarUrl: user.data.file_path
                                })
							}
						});
					}
				});
			},
  /**
   * 获取我的团队信息
   */
  getteaminfo() {
    let _this = this;
    App._post_form('user.team/getMyInfoByTeam', {}, (result) => {
        this.setData({
            team_name:result.data.team_name,
            team_avatarUrl:result.data.team_avatarUrl,
            team_remark:result.data.team_remark
        })
    });
  },
  handlebtn(){
    App._post_form('user.team/updateTeamInfo', {
        team_name:this.data.team_name,
        team_avatarUrl:this.data.team_avatarUrl,
        team_remark:this.data.team_remark       
    }, (result) => {
       wx.navigateTo({
         url: './home/index',
       })
    });
  },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getteaminfo()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})